﻿package com.amcharts.geom
{
    import com.amcharts.utils.*;
    import flash.display.*;

    public class Cuboid extends ExtendedSprite
    {
        private var _container:Sprite;
        private var _bwidth:Number;
        private var _colors:Array;
        private var _cornerRadiuses:Array;
        private var _balpha:Number;
        private var _bcolor:uint;
        private var _h:Number;
        private var _gradientRotation:Number;
        private var _dy:Number;
        private var _w:Number;
        private var _dx:Number;
        private var _alphas:Array;
        static const VERSION:String = "1.8.3.1";

        public function Cuboid(param1:Number, param2:Number, param3:Number, param4:Number, param5:Array, param6:Array, param7:uint = 0, param8:uint = 0, param9:Number = 0, param10:Number = 1.5708, param11:Array = null)
        {
            var _loc_14:Array = null;
            var _loc_15:uint = 0;
            var _loc_12:* = param5.length;
            var _loc_13:* = param6.join(",").split(",");
            if (_loc_12 > 0)
            {
                _loc_14 = new Array();
                _loc_15 = 0;
                while (_loc_15 < _loc_12)
                {
                    
                    _loc_14[_loc_15] = 255 / (param5.length - 1) * _loc_15;
                    if (_loc_13[_loc_15] == undefined)
                    {
                        _loc_13[_loc_15] = param6[(_loc_15 - 1)];
                    }
                    _loc_13[_loc_15] = _loc_13[_loc_15];
                    _loc_15 = _loc_15 + 1;
                }
            }
            _h = -param2;
            _w = param1;
            _dx = param3;
            _dy = param4;
            _colors = param5;
            _alphas = _loc_13;
            _bwidth = param7;
            _bcolor = param8;
            _balpha = param9;
            _gradientRotation = param10;
            _cornerRadiuses = [0, 0, 0, 0];
            if (_dx == 0)
            {
            }
            if (_dy == 0)
            {
                _cornerRadiuses = param11;
            }
            _container = new Sprite();
            addChild(_container);
            init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_3:Polygon = null;
            var _loc_4:Line = null;
            var _loc_5:Rect = null;
            var _loc_6:Line = null;
            var _loc_7:Polygon = null;
            var _loc_8:Polygon = null;
            var _loc_9:Line = null;
            var _loc_10:Polygon = null;
            var _loc_11:Line = null;
            Utils.removeChildren(_container);
            var _loc_1:Number = 0;
            if (_dx <= 0)
            {
            }
            if (_dy > 0)
            {
                _loc_3 = new Polygon([0, _dx, _w + _dx, _w, 0], [0, _dy, _dy, 0, 0], [_colors[(_colors.length - 1)]], [_alphas[(_alphas.length - 1)]], 0, 0, 0, _gradientRotation);
                _loc_3.doubleClickEnabled = true;
                _container.addChild(_loc_3);
                if (_h < 0)
                {
                    Utils.adjustBrightness(_loc_3, 1.1);
                }
                else
                {
                    Utils.adjustBrightness(_loc_3, 0.6);
                }
                _loc_4 = new Line([0, _dx, _w + _dx], [0, _dy, _dy], _bcolor, _balpha, _bwidth);
                _container.addChild(_loc_4);
                _loc_5 = new Rect(_w, _h, _colors, _alphas, 0, 0, 0, 0, _gradientRotation);
                _container.addChild(_loc_5);
                _loc_5.y = -_h + _dy;
                _loc_5.x = _dx;
                Utils.adjustBrightness(_loc_5, 0.8);
                _loc_6 = new Line([_dx, _dx], [_dy, -_h + _dy], _bcolor, _balpha, _bwidth);
                _container.addChild(_loc_6);
                _loc_7 = new Polygon([0, 0, _dx, _dx, 0], [0, -_h, -_h + _dy, _dy, 0], _colors, _alphas, 0, 0, 0, _gradientRotation);
                _container.addChild(_loc_7);
                Utils.adjustBrightness(_loc_7, 0.9);
                _loc_8 = new Polygon([0, 0, _dx, _dx, 0], [0, -_h, -_h + _dy, _dy, 0], _colors, _alphas, 0, 0, 0, _gradientRotation);
                _loc_8.doubleClickEnabled = true;
                _container.addChild(_loc_8);
                _loc_8.x = _w;
                Utils.adjustBrightness(_loc_8, 0.8);
                _loc_9 = new Line([0, _dx, _dx, 0], [-_h, -_h + _dy, _dy, 0], _bcolor, _balpha, _bwidth);
                _container.addChild(_loc_9);
                _loc_9.x = _w;
                _loc_10 = new Polygon([0, _dx, _w + _dx, _w, 0], [0, _dy, _dy, 0, 0], [_colors[0]], [_alphas[0]], 0, 0, 0, _gradientRotation);
                _loc_10.doubleClickEnabled = true;
                _container.addChild(_loc_10);
                if (_h < 0)
                {
                    Utils.adjustBrightness(_loc_10, 0.6);
                }
                else
                {
                    _loc_10.y = -_h;
                    Utils.adjustBrightness(_loc_10, 1.1);
                }
                _loc_11 = new Line([0, _dx, _w + _dx], [0, _dy, _dy], _bcolor, _balpha, _bwidth);
                _container.addChild(_loc_11);
                _loc_11.y = -_h;
                if (_h < 0)
                {
                    _container.setChildIndex(_loc_11, 0);
                    _container.setChildIndex(_loc_10, 0);
                    _container.setChildIndex(_loc_3, (_container.numChildren - 1));
                    _container.setChildIndex(_loc_4, (_container.numChildren - 1));
                }
            }
            var _loc_2:* = new Rect(Math.abs(_w), Math.abs(_h), _colors, _alphas, _bwidth, _bcolor, _balpha, _cornerRadiuses, _gradientRotation);
            _loc_2.y = -_h;
            _loc_2.doubleClickEnabled = true;
            if (_h < 0)
            {
                _loc_2.y = 0;
            }
            if (_w < 0)
            {
                _loc_2.x = _w;
            }
            _container.addChild(_loc_2);
            return;
        }// end function

        public function set h(param1:Number) : void
        {
            _h = -param1;
            init();
            return;
        }// end function

        public function set w(param1:Number) : void
        {
            _w = param1;
            init();
            return;
        }// end function

    }
}
